package top.lyunk.demo.server.a.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import top.lyunk.demo.server.a.ServerAService;
import top.lyunk.demo.server.b.rpc.dubbo.dubbo.ServerBDubboAPI;

@RestController
public class ServerAController {


    @Autowired
    private ServerBDubboAPI serverBDubboAPI;
    @Autowired
    private ServerAService serverAService;

    @GetMapping(value = "/echo/{string}")
    public String echo(@PathVariable String string) {
        return "Hello Nacos Discovery " + string;
    }

    @GetMapping(value = "/echo/serverB/{string}")
    public String echoServerB(@PathVariable String string) {
        return serverBDubboAPI.echo(string);
    }

    @GetMapping("/config/testUserId")
    public Long get() {
        return serverAService.getTestUserId();
    }

    @GetMapping("/addUser/{id}/{name}/{age}/{error}")
    public int addUser(@PathVariable long id, @PathVariable String name, @PathVariable Integer age, @PathVariable boolean error) {
        return serverAService.addUser(id, name, age, error);
    }
}
